#include<stdio.h>

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)>(b)?(b):(a))

int maxProfit(int* prices, int pricesSize) {
    int minprice=1e9;
    int maxprofit=0;
    for(int i=0;i<pricesSize;i++)
    {
        maxprofit = MAX(maxprofit,prices[i]-minprice);
        minprice = MIN(minprice,prices[i]);
    }
    return maxprofit;
}